package com.example.demo.controller;

import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Title: TestSwaggerController
 * Description:
 *
 * @author yuqz
 * @date 2020/7/8 9:54
 */
@RestController
@RequestMapping("/swagger")
@Api(tags="说明该类的作用",value="该参数没什么意义，所以不需要配置")
public class TestSwaggerController {
    @GetMapping(value = "/test")
    @ApiOperation(value = "说明方法的作用",notes = "方法的备注说明")
    //字符串 与参数命名对应  value：参数中文描述 required：是否必传 dataType：参数类型
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "用户名", required = true, dataType = "String"),
            @ApiImplicitParam(name = "password", value = "密码", required = true, dataType = "String")
    })
    @ApiResponses({
        @ApiResponse(code = 200,message = "请求成功",response = DTO.class),
        @ApiResponse(code = 500,message = "参数有误",response = DTO.class)
    })
    public DTO insert(Command command){
        DTO dto = new DTO();
        dto.setStatus(200);
        dto.setMsg("success");
        dto.setData(command.getName()+command.getPassword());
        return dto;
    }
}
